﻿Public Class frmArriendo



    Private Sub txtSede_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtSede.KeyPress
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If
    End Sub




    Private Sub txtLocal_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLocal.KeyPress
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If
    End Sub

    Private Sub txtGarantia_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtGarantia.KeyPress
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If
    End Sub

    Private Sub txtPago1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPago1.KeyPress
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If
    End Sub
    Private Sub txtPago2_KeyPress(sender As Object, e As KeyPressEventArgs)
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If
    End Sub





    Private Sub txtSede_TextChanged(sender As Object, e As EventArgs) Handles txtSede.TextChanged
        Try
            If txtSede.TextLength = 0 Then
                txtTotal.Text = sumaArriendo(0, CInt(txtLocal.Text), CInt(txtGarantia.Text), CInt(txtPago1.Text))
            Else
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), CInt(txtLocal.Text), CInt(txtGarantia.Text), CInt(txtPago1.Text))
            End If

        Catch ex As Exception
            '' Error al crear el formulario InvalidOperationException

        End Try

    End Sub

    Private Sub txtLocal_TextChanged(sender As Object, e As EventArgs) Handles txtLocal.TextChanged

        Try
            If txtLocal.TextLength = 0 Then
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), 0, CInt(txtGarantia.Text), CInt(txtPago1.Text))
            Else
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), CInt(txtLocal.Text), CInt(txtGarantia.Text), CInt(txtPago1.Text))
            End If

        Catch ex As Exception
            '' Error al crear el formulario InvalidOperationException
        End Try


    End Sub




    Private Sub txtGarantia_TextChanged(sender As Object, e As EventArgs) Handles txtGarantia.TextChanged
        Try
            If txtGarantia.TextLength = 0 Then
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), CInt(txtLocal.Text), 0, CInt(txtPago1.Text))
            Else
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), CInt(txtLocal.Text), CInt(txtGarantia.Text), CInt(txtPago1.Text))
            End If

        Catch ex As Exception
            '' Error al crear el formulario InvalidOperationException
        End Try

    End Sub

    Private Sub txtPago1_TextChanged(sender As Object, e As EventArgs) Handles txtPago1.TextChanged
        Try
            If txtPago1.TextLength = 0 Then
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), CInt(txtLocal.Text), CInt(txtGarantia.Text), 0)
            Else
                txtTotal.Text = sumaArriendo(CInt(txtSede.Text), CInt(txtLocal.Text), CInt(txtGarantia.Text), CInt(txtPago1.Text))
            End If

        Catch ex As Exception
            '' Error al crear el formulario InvalidOperationException
        End Try

    End Sub



    Private Sub txtSede_GotFocus(sender As Object, e As EventArgs) Handles txtSede.GotFocus
        If txtSede.Text = "0" Then
            txtSede.Clear()
        End If

    End Sub

    Private Sub txtLocal_GotFocus(sender As Object, e As EventArgs) Handles txtLocal.GotFocus
        If txtLocal.Text = "0" Then
            txtLocal.Clear()
        End If
    End Sub

    Private Sub txtGarantia_GotFocus(sender As Object, e As EventArgs) Handles txtGarantia.GotFocus
        If txtGarantia.Text = "0" Then
            txtGarantia.Clear()
        End If
    End Sub

    Private Sub txtPago1_GotFocus(sender As Object, e As EventArgs) Handles txtPago1.GotFocus
        If txtPago1.Text = "0" Then
            txtPago1.Clear()
        End If
    End Sub



    Private Sub txtSede_LostFocus(sender As Object, e As EventArgs) Handles txtSede.LostFocus
        If txtSede.TextLength = 0 Then
            txtSede.Text = 0
        End If
    End Sub

    Private Sub txtLocal_LostFocus(sender As Object, e As EventArgs) Handles txtLocal.LostFocus
        If txtLocal.TextLength = 0 Then
            txtLocal.Text = 0
        End If
    End Sub

    Private Sub txtGarantia_LostFocus(sender As Object, e As EventArgs) Handles txtGarantia.LostFocus
        If txtGarantia.TextLength = 0 Then
            txtGarantia.Text = 0
        End If
    End Sub

    Private Sub txtPago1_LostFocus(sender As Object, e As EventArgs) Handles txtPago1.LostFocus
        If txtPago1.TextLength = 0 Then
            txtPago1.Text = 0
        End If
    End Sub


    Private Sub frmArriendo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        datosCBPagosArriendo()
    End Sub

    Private Sub btnPagar_Click(sender As Object, e As EventArgs) Handles btnPagar.Click
        Try
            If txtNombre.TextLength = 0 Then
            Else
                ingresaPagoArriendo(dtp1.Value.ToShortDateString, cbFormasDePago.SelectedValue, txtNumeroDocumento.Text, txtTotal.Text, txtNombre.Text, txtSede.Text, txtLocal.Text, txtGarantia.Text, txtPago1.Text, txtObservaciones.Text)
                Dim frmVisor As New frmVisorDePagoArriendo
                frmVisor.idPago = idCRArriendo
                frmVisor.Show()
            End If
        Catch ex As Exception
            mensajeError(ex)
        End Try
    End Sub


End Class